<?php
namespace App\Http\Controllers\Api;

use App\Requests\NewsCateRequest;
use App\Requests\NewsIdRequest;
use App\Services\NewsService;
use Carbon\Carbon;
use Framework\BaseController;
use Framework\Hope;



class NewsController extends BaseController
{

    public function cate_news(NewsService $Service)
    {
        $info = $Service->cate_news();
        $this->retSuccess($info);
    }

    public function newsList(NewsCateRequest $request,NewsService $Service)
    {
        $size = $request->input('size',10);
        $page = $request->input('page',1);
        $cate_id = $request->input('cate_id');
        $is_elite = $request->input('is_elite');
        $info = $Service->newsList($cate_id, $is_elite, $size, $page);
        $this->retSuccess($info);
    }

    public function newsDetails(NewsIdRequest $request,NewsService $Service)
    {
        $user_id = $this->getAuthId();
        $news_id = $request->news_id();
        $info = $Service->newsDetails($user_id,$news_id);
        $this->retSuccess($info);
    }

    public function collectNews(NewsIdRequest $request,NewsService $Service)
    {
        $user_id = $this->getAuthId();
        $news_id = $request->news_id();
        $type = $request->input('type',3);
        $is_collect = $request->input('is_collect',1);
        $info = $Service->collectNews($user_id,$news_id,$type,$is_collect);
        $this->retSuccess($info);
    }


}
